<template>
  <van-nav-bar
    :title="title"
    left-arrow
    @click-left="onClickLeft"
    @click-right="onClickRight"
  >
    <template #right v-if="right">
      <span>{{ store.state.isIn ? "完成" : "编辑" }}</span>
    </template>
  </van-nav-bar>
</template>

<script setup>
defineProps(["title", "right"]);
import { useStore } from "vuex";
import { ref } from "vue";
import { showToast } from "vant";
let isIn = ref(true);
const store = useStore();
const onClickLeft = () => history.back();

const onClickRight = () => {
  if (store.state.cartList.length !== 0) {
    store.commit("CHANGEBUY");
    store.commit("CHANGEISIN");
  } else {
    showToast("购物车为空，请添加商品");
  }
};
</script>

<style lang="less" scoped>
/deep/.van-nav-bar__text {
  color: #333;
}
/deep/.van-nav-bar__left {
  .van-icon {
    color: #333;
  }
}
</style>
